package org.esk.dablog.model.comments;

import org.esk.dablog.model.Comment;

import javax.persistence.Entity;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Transient;

/**
 * This class
 * User: jc
 * Date: 01.12.2006
 * Time: 19:24:55
 * $Id:$
 *
 * @hibernate.subclass
 *   discriminator-value="2"
 *
 */
@Entity
@DiscriminatorValue("2")
public class ForumComment extends Comment {
    private static final int STATE_NORMAL = 0;
    private static final int STATE_HIDDEN = 1;

    @Transient
    public boolean isHidden() {
        boolean hidden = this.getState() == STATE_HIDDEN;
        if (!hidden && getParent() != null && getParent() instanceof ForumComment) {
            return ((ForumComment) getParent()).isHidden();
        }
        return hidden;
    }

}
